﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StringCalc
{
    class Program
    {
        static void Main(string[] args)
        {
        }
    }

    public class Calculator
    {
        public int add(string numbers)
        {
            if (numbers.Equals(""))
                return -1;
            int sum = 0;
            string negatives = "";
            if (numbers.Length == 1)
                return Convert.ToInt32(numbers);
            string[] nums;
            int num;
            if (numbers.Substring(0, 2).Equals("//"))
            {
                char delimiter = numbers.ToCharArray()[2];
                nums = numbers.Substring(4).Split(new Char[] { delimiter });
            }
            else nums = numbers.Split(new Char[] {',', '\n'});
            foreach (string s in nums)
            {
                num = Convert.ToInt32(s);
                if (Convert.ToInt32(s) < 0)
                    negatives += s;
                sum += num;
            }
            if (negatives.Length != 0)
                throw new ArgumentException("negatives not allowed: " + negatives);
            return sum;
        }
    }

}
